<?php
/**
 * 作者：亿泽
 * QQ：1260435972
 * 交流群：557649112
 * 日期：2022/03/31
 * 项目名称：亿泽不用验证系统
 * 项目说明：请勿进行违法用途，当您在使用本项目中的任何源代码时默认同意作者的观点！
 * 观点：
 * 1.禁止将本系统使用于违法违规用途。
 * 2.禁止将本系统使用包含但不限于 灰色产业/进行灰色产业的机器人插件/框架。
 * 3.禁止进行商业性质的二创二开，仅授权免费个人使用
 * 4.本系统为免费/全开源项目，禁止进行任何商业活动 除非 获得作者授权！
 * 感谢：
 * 1.使用了 光年 后台模板
 * 2.参考了 网络上部分代码资料
 * 3.感谢各位的使用~
 **/
require_once "../include/common.php";
require_once "header.php";
$title = '版本增加 - 亿泽不用验证后台管理系统';
if ($islogin == 1) {
} else exit("<script>window.location.href='./login.html';</script>");
?>
<link href="js/bootstrap-datetimepicker/bootstrap-datetimepicker.min.css" rel="stylesheet">
<?php
if (isset($_POST['submit'])) {
    $appid = daddslashes ($_POST['appid']);
    $appver = daddslashes ($_POST['appver']);
    $title = daddslashes ($_POST['title']);
    $subtitle = daddslashes ($_POST['subtitle']);
    $vername = daddslashes ($_POST['vername']);
    $free = daddslashes ($_POST['free']);
    $update = daddslashes ($_POST['update']);
    $log = daddslashes ($_POST['log']);
    $download = daddslashes ($_POST['download']);
    $affiche = daddslashes ($_POST['affiche']);
    $expire = strtotime(daddslashes ($_POST['expire']));
    $auth = daddslashes ($_POST['auth']);
    $enable = daddslashes ($_POST['enable']);

    $row = Db ::table ("appver") -> rawexec ("INSERT INTO `yz_appver` ( `bd_appid`, `version`, `title`, `subtitle`, `vername`, `free`, `update`, `log`, `download`, `affiche`, `expire`, `auth`, `enable`) VALUES (' $appid', '$appver', '$title', '$subtitle', '$vername', '$free', '$update', '$log', '$download', '$affiche', '$expire', '$auth', '$enable');");
    if($row != 0){
        exit(popup ("新增成功" , 2));
    }else{
        exit(popup ("新增失败" , 3));
    }

}
?>
<div class="container-fluid p-t-15">
    <div class="row">
        <div class="col-lg-12">
            <div class="card">
                <header class="card-header">
                    <div class="card-title"><a href="app_list.php" data-toggle="tooltip" data-original-title="返回版本列表"
                                               class="mdi mdi-reply-all"> &nbsp;</a>&nbsp;新增应用版本
                    </div>
                </header>
                <div class="card-body">
                    <form action="ver_add.php" method="post">
                        <div class="form-row">
                            <div class="input-group">
                                <div class="col-md-6 mb-3">
                                    <div class="input-group-prepend">
                                        <span class="input-group-text">应用选择</span>
                                    </div>
                                    <select class="custom-select" name="appid" id="validationTooltip04" required>
                                        <option selected disabled value="">请选择...</option>
                                        <?php
                                        $re = Db ::table ("applist") -> find ("*");
                                        while ($row = $re -> fetch ()) {
                                            $s1 = $row['name'];
                                            $s2 = $row['appid'];
                                            echo '<option value="'.$s2.'">名称：' . $s1 . ' | ID：' . $s2 . '</option>';
                                        }
                                        ?>
                                    </select>
                                    <div class="invalid-tooltip">
                                        请选择有效状态。
                                    </div>
                                </div>
                                <div class="col-md-6 mb-3">
                                    <div class="input-group-prepend">
                                        <span class="input-group-text">版本</span>
                                    </div>
                                    <select class="custom-select" name="vername" id="validationTooltip04" required>
                                        <option selected disabled value="">请选择...</option>
                                        <option value="0">- 预览版 - Pre-alpha</option>
                                        <option value="1">- 内测版 - Alpha</option>
                                        <option value="2">- 公测版 - Beta</option>
                                        <option value="3">- 最终测试版 - Gamma</option>
                                        <option value="4">- 稳定版 - Stable</option>
                                        <option value="5">- 发行版 - Release</option>
                                        <option value="6">- 零售版 - Retail</option>
                                    </select>
                                    <div class="invalid-tooltip">
                                        请选择有效状态。
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="input-group mb-3">
                            <div class="input-group-prepend">
                                <span class="input-group-text">版本号</span>
                            </div>
                            <input type="text" class="form-control" name="appver" value="<?= @$_POST['appver'] ?>"
                                   placeholder="请输入版本号，请注意格式！">
                        </div>

                        <div class="input-group mb-3">
                            <div class="input-group-prepend">
                                <span class="input-group-text">标题</span>
                            </div>
                            <input type="text" class="form-control" name="title" value="<?= @$_POST['title'] ?>"
                                   placeholder="请输入标题">
                        </div>

                        <div class="input-group mb-3">
                            <div class="input-group-prepend">
                                <span class="input-group-text">副标题</span>
                            </div>
                            <input type="text" class="form-control" name="subtitle" value="<?= @$_POST['subtitle'] ?>"
                                   placeholder="请输入副标题">
                        </div>
                        <div class="input-group mb-3">
                            <div class="input-group-prepend">
                                <span class="input-group-text">收费模式</span>
                            </div>
                            <select class="custom-select" name="free" required>
                                <option selected value="0">免费</option>
                                <option value="1">收费</option>
                            </select>
                            <div class="invalid-tooltip">
                                请选择收费模式。
                            </div>
                        </div>
                        <div class="form-row">
                            <div class="input-group">
                                <div class="col-md-6 mb-3">
                                    <div class="input-group-prepend">
                                        <span class="input-group-text">更新日期</span>
                                    </div>
                                    <input class="form-control" type="text" data-provide="datetimepicker" name="update"
                                           placeholder="请选择具体时间" value="<?php echo date ('Y-m-d H:i:s'); ?>"
                                           data-side-by-side="true"
                                           data-format="YYYY-MM-DD HH:mm:ss"/>
                                </div>
                                <div class="col-md-6 mb-3">
                                    <div class="input-group-prepend">
                                        <span class="input-group-text">结束时间</span>
                                    </div>
                                    <input class="form-control" type="text" data-provide="datetimepicker" name="expire"
                                           placeholder="请选择具体时间" value="<?php echo date ('Y-m-d H:i:s'); ?>')"
                                           data-side-by-side="true"
                                           data-format="YYYY-MM-DD HH:mm:ss"/>
                                </div>
                            </div>
                        </div>

                        <div class="input-group-prepend mb-3">
                            <span class="input-group-text">公告说明</span>
                            <textarea class="form-control" name="affiche"
                                      aria-label="With textarea"><?= @$_POST['affiche'] ?></textarea>
                        </div>

                        <div class="input-group-prepend mb-3">
                            <span class="input-group-text">更新日志</span>
                            <textarea class="form-control" name="log"
                                      aria-label="With textarea"><?= @$_POST['log'] ?></textarea>
                        </div>

                        <div class="input-group mb-3">
                            <div class="input-group-prepend">
                                <span class="input-group-text">下载链接</span>
                            </div>
                            <input type="text" class="form-control" name="download" value="<?= @$_POST['download'] ?>"
                                   placeholder="请输入该版本的下载链接！">
                        </div>

                        <div class="input-group mb-3">
                            <div class="input-group-prepend">
                                <span class="input-group-text">验证模式</span>
                            </div>
                            <select class="custom-select" name="auth" required>
                                <option selected value="0">无需验证</option>
                                <option value="1">账号密码验证</option>
                                <option value="2">卡密授权验证</option>
                            </select>
                            <div class="invalid-tooltip">
                                请选择验证模式。
                            </div>
                        </div>

                        <div class="input-group mb-3">
                            <span class="input-group-text"><input type="radio" id="status1" name="enable" value="1"
                                                                  checked>&nbsp;正常</span>
                            <span class="input-group-text"><input type="radio" id="status2" name="enable" value="2">&nbsp;维护</span>
                            <span class="input-group-text"><input type="radio" id="status3" name="enable" value="0">&nbsp;禁用</span>
                        </div>
                        <div class="input-group">
                            <input class="btn btn-block btn-label btn-primary" type="submit" name="submit" value="新增">
                        </div>
                    </form>
                </div>
            </div>
        </div>

    </div>

</div>
<!--时间日期选择器-->
<script type="text/javascript" src="js/moment.js/moment.min.js"></script>
<script type="text/javascript" src="js/bootstrap-datetimepicker/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript" src="js/moment.js/locale/zh-cn.min.js"></script>
